package com.angel.webapp.application;

import com.angel.common.keyValue.KeyValueResult;
import com.angel.webapp.actions.ActionStrategy;

/**
 * @author William
 * @since 03/February/2009
 */
public class ApplicationActionStrategies {

    private static ApplicationActionStrategies INSTANCE;

    private KeyValueResult keyValueResult;

    private ApplicationActionStrategies(){
        super();
    }

    public synchronized static ApplicationActionStrategies createInstance(){
        if(INSTANCE == null){
            INSTANCE = new ApplicationActionStrategies();
        }
        return INSTANCE;
    }

    public KeyValueResult getKeyValueResult() {
        return keyValueResult;
    }

    public void setKeyValueResult(KeyValueResult keyValueResult) {
        this.keyValueResult = keyValueResult;
    }

    public ActionStrategy findActionStrategy(String name){
        return (ActionStrategy) this.getKeyValueResult().getResultFor(name);
    }
    
    public void addActionStrategy(String name, ActionStrategy actionStrategy){
        this.getKeyValueResult().addKeyValue(name, actionStrategy);
    }
    
    public void removeActionStrategy(String name, ActionStrategy actionStrategy){
        this.getKeyValueResult().removeKeyValue(name);
    }

    public boolean containsActionStrategy(String name){
        return this.keyValueResult.containsResultFor(name);
    }
}